<!DOCTYPE html>
<html lang="en">
    <head>
        <title></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1">
        <title>html5 webapp 组件</title>
        <style>
            body {
                margin: 0;
                padding: 0;
            }
            .component{
                width: 50%;
                height: 30px;
                margin-bottom: 20px;
                background-color: #eeeeee;
                display: none;
            }
        </style>
        <script src="../js/lib/jquery.js"></script>
        <script src="../js/lib/jquery-ui.min.js"></script>
        <script src="../js/lib/jquery.fullPage.js"></script>
        <script>
            $(function () {
                $('#h5').fullpage({
                    'sectionsColor':['#254875','#00ff00','#695684'],
                    onLeave:function (index,nextIndex,direction) {
                        $('#h5').find('.page').eq(index-1).trigger('onLeave');
                    },
                    afterLoad:function (anchorLink,index) {
                        $('#h5').find('.page').eq(index-1).trigger('onLoad');
                    },
                });
                $('.page').on('onLeave',function () {
                    console.log($(this).attr('id'),'===>>','onLeave');
                    $(this).find('.component').trigger('onLeave');
                });
                $('.page').on('onLoad',function () {
                    console.log($(this).attr('id'),'===>>','onLoad');
                    $(this).find('.component').trigger('onLoad');
                });
                $('.component').on('onLoad',function () {
                    $(this).fadeIn();
                    return false;
                });
                $('.component').on('onLeave',function () {
                    $(this).fadeOut();
                    return false;
                });
            });
        </script>
    </head>
    <body>
    <!-- 用于验证 fullpage.js 切换页面，一级内容结构可用，组件能够进行动画 -->
        <div id="h5">
            <div class="page section" id="page-1">
                <div class="component log">logo</div>
                <div class="component slogn">slogn</div>
            </div>
            <div class="page section" id="page-2">
                <div class="component desc">页面描述</div>
            </div>
            <div class="page section" id="page-3">
                <div class="component bar">柱状图</div>
            </div>
        </div>

    </body>
</html>